<template>
	<el-drawer :title="titleMap[mode]" v-model="visible" :size="600" append-to-body destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main class="nopadding">
				<el-scrollbar>
					<el-row class="drawer-table">
						<el-col :span="24">
							<el-form :model="form" :rules="rules" :disabled="mode==='show'" ref="dialogForm" label-width="80px">
								<el-form-item label="广告传媒订单" prop="ggcmOrderId">
									<el-input v-model="form.userName" placeholder="请输入广告传媒订单" clearable></el-input>
								</el-form-item>
								<el-form-item label="会员" prop="appUserId">
									<el-input v-model="form.userName" placeholder="请输入会员" clearable></el-input>
								</el-form-item>
								<el-form-item label="分公司" prop="companyId">
									<el-input v-model="form.userName" placeholder="请输入分公司" clearable></el-input>
								</el-form-item>
								<el-form-item label="店铺" prop="sysDepartmentId">
									<el-input v-model="form.userName" placeholder="请输入店铺" clearable></el-input>
								</el-form-item>
								<el-form-item label="销售员" prop="xsSuserId">
									<el-input v-model="form.userName" placeholder="请输入销售员" clearable></el-input>
								</el-form-item>
								<el-form-item label="项目总监" prop="jkSuserId">
									<el-input v-model="form.userName" placeholder="请输入项目总监" clearable></el-input>
								</el-form-item>
								<el-form-item label="核销单 现结 不需要核销单" prop="ggcmMoneyId">
									<el-input v-model="form.userName" placeholder="请输入核销单 现结 不需要核销单" clearable></el-input>
								</el-form-item>
								<el-form-item label="订单产品数量 产品项目数" prop="productSl">
									<el-input v-model="form.userName" placeholder="请输入订单产品数量 产品项目数" clearable></el-input>
								</el-form-item>
								<el-form-item label="0无效 1暂存待确认 2客户已提交   3生效执行中 8已完成  10已完成结束" prop="orderState">
									<el-input v-model="form.userName" placeholder="请输入0无效 1暂存待确认 2客户已提交   3生效执行中 8已完成  10已完成结束" clearable></el-input>
								</el-form-item>
								<el-form-item label=">0 异常订单" prop="ycState">
									<el-input v-model="form.userName" placeholder="请输入>0 异常订单" clearable></el-input>
								</el-form-item>
								<el-form-item label="订单总金额" prop="sumMoney">
									<el-input v-model="form.userName" placeholder="请输入订单总金额" clearable></el-input>
								</el-form-item>
								<el-form-item label="订单总金额 则后金额" prop="sumMoneyZh">
									<el-input v-model="form.userName" placeholder="请输入订单总金额 则后金额" clearable></el-input>
								</el-form-item>
								<el-form-item label="成本" prop="sumMoneyCb">
									<el-input v-model="form.userName" placeholder="请输入成本" clearable></el-input>
								</el-form-item>
								<el-form-item label="优先级" prop="doLevel">
									<el-input v-model="form.userName" placeholder="请输入优先级" clearable></el-input>
								</el-form-item>
								<el-form-item label="建单人" prop="createId">
									<el-input v-model="form.userName" placeholder="请输入建单人" clearable></el-input>
								</el-form-item>
								<el-form-item label="建单时间" prop="createTime">
									<el-input v-model="form.userName" placeholder="请输入建单时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="提交时间" prop="tjTime">
									<el-input v-model="form.userName" placeholder="请输入提交时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="提成计算时间" prop="tcTime">
									<el-input v-model="form.userName" placeholder="请输入提成计算时间" clearable></el-input>
								</el-form-item>
								<el-form-item label="说明" prop="msg">
									<el-input v-model="form.userName" placeholder="请输入说明" clearable></el-input>
								</el-form-item>
								<el-form-item label="" prop="hxState">
									<el-input v-model="form.userName" placeholder="请输入" clearable></el-input>
								</el-form-item>
								<el-form-item label="核销日期" prop="hxDate">
									<el-input v-model="form.userName" placeholder="请输入核销日期" clearable></el-input>
								</el-form-item>
                            </el-form>
						</el-col>
					</el-row>
				</el-scrollbar>
			</el-main>
			<el-footer>
				<el-button v-if="mode!=='show'" :loading="isSaveing" @click="submit()" type="primary" size="small">保 存</el-button>
				<el-button size="small" @click="visible=false">取 消</el-button>
			</el-footer>
		</el-container>
	</el-drawer>
</template>
<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '新增',
					edit: '编辑',
					mode: ''
				},
				visible: false,
				isSaveing: false,
				//表单数据
				form: {
					ggcmOrderId: "",
					appUserId: "",
					companyId: "",
					sysDepartmentId: "",
					xsSuserId: "",
					jkSuserId: "",
					ggcmMoneyId: "",
					productSl: "",
					orderState: "",
					ycState: "",
					sumMoney: "",
					sumMoneyZh: "",
					sumMoneyCb: "",
					doLevel: "",
					createId: "",
					createTime: "",
					tjTime: "",
					tcTime: "",
					msg: "",
					hxState: "",
					hxDate: "",
				},
				//验证规则
				rules: {
					userName: [
						{required: true, message: '请输入名称'}
					],
					userAge: [
						{pattern: /^[0-9]*$/, message: '年龄需为数字', trigger: 'blur'}
					],
					price: [
						{pattern: /^\d+(\.\d+)?$/, message: '价格需为数字', trigger: 'blur'}
					]
				}
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(mode='add'){
				this.mode = mode;
				this.visible = true;
				return this;
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if(valid){
						this.isSaveing = true;
						var res = await this.$API.ggcm.ggcmOrder.save.post(this.form);
						this.isSaveing = false;
						if(res.code === 2000){
							this.$emit('success', this.form, this.mode);
							this.visible = false;
							this.$message.success(res.message);
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}
				});
			},
			//表单注入数据
			setData(data){
				this.form.ggcmOrderId = data.ggcmOrderId;
				this.form.appUserId = data.appUserId;
				this.form.companyId = data.companyId;
				this.form.sysDepartmentId = data.sysDepartmentId;
				this.form.xsSuserId = data.xsSuserId;
				this.form.jkSuserId = data.jkSuserId;
				this.form.ggcmMoneyId = data.ggcmMoneyId;
				this.form.productSl = data.productSl;
				this.form.orderState = data.orderState;
				this.form.ycState = data.ycState;
				this.form.sumMoney = data.sumMoney;
				this.form.sumMoneyZh = data.sumMoneyZh;
				this.form.sumMoneyCb = data.sumMoneyCb;
				this.form.doLevel = data.doLevel;
				this.form.createId = data.createId;
				this.form.createTime = data.createTime;
				this.form.tjTime = data.tjTime;
				this.form.tcTime = data.tcTime;
				this.form.msg = data.msg;
				this.form.hxState = data.hxState;
				this.form.hxDate = data.hxDate;
			}
		}
	}
</script>
<style>
</style>
